-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add example mock "kubectl get configmap xx -o json" #639
Conversation
Welcome @ZP-AlwaysWin! |
/assign @mbohlool |
* | ||
* <p>From inside $REPO_DIR/examples | ||
* | ||
* <p>mock "kubectl get configamp configmap-name -o json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the point of adding this example? i don't think this example worth a new file..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @yue9944882
I use java-client to work for pass platform, I need to get xxx.json to change, mock kubectl get resourcename -o json。but Under the existing examples,I don't konw how to do it. Stand in the user's Perspective ,I add example。
It's up to you to decide.
Best Wishes
This is probably a good thing to add to the ParseExample.java instead of a brand new example. Thanks! |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ZP-AlwaysWin The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
I already add the example to the ParseExample.java, I am using the java-client to work for paas , If I find any minor problems or usability problems, I will contribute. Best Wishes |
|
||
String body = response.body().string(); | ||
|
||
JsonObject returnData = new JsonParser().parse(body).getAsJsonObject(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this work with the custom-type adapter? in the existing example, it's parsing by using the nested gson instance where we register the adapters?
Object obj2 = client
.getJSON()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm, I think that Gson adapters are injected via annotation so that they would work everywhere, e.g. https://github.com/kubernetes-client/java/blob/master/kubernetes/src/main/java/io/kubernetes/client/custom/Quantity.java#L14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
java/kubernetes/src/main/java/io/kubernetes/client/JSON.java
Lines 46 to 54 in 607a34b
public JSON() { | |
gson = new GsonBuilder() | |
.registerTypeAdapter(Date.class, dateTypeAdapter) | |
.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter) | |
.registerTypeAdapter(DateTime.class, dateTimeTypeAdapter) | |
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter) | |
.registerTypeAdapter(byte[].class, byteArrayTypeAdapter) | |
.create(); | |
} |
but here we're registering the adapters explicitly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's true for those built-ins we can't annotate...
Closing this since it is old. Please feel free to re-open if there are updates. |
add example mock "kubectl get configmap xx -o json"